#region File Info
// File: Exceptions.cs
// Product: Ebnf Visualizer
// Types: 
//    class EbnfException
//    class SyntaxException
//    class LexicalException
// License:
// Copyright (C) 2010 Daniel Kuschny (http://www.coderline.net)
//
// This file is part of Ebnf Visualizer.
//
// Ebnf Visualizer is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Ebnf Visualizer is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Ebnf Visualizer. If not, see <http://www.gnu.org/licenses/>.
#endregion

using System;

namespace EbnfVisualizer
{
    /// <summary>
    /// Die Basis-Exception welche bei Fehlern im <see cref="EbnfParser"/> geworfen werden.
    /// </summary>
    [Serializable]
    public class EbnfException : Exception
    {
        /// <summary>
        /// Ruft die Position im Quellcode ab, an welcher der Fehler aufgetreten ist.
        /// </summary>
        /// <value>The position.</value>
        public int Position { get; private set; }

        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="EbnfException"/>-Klasse.
        /// </summary>
        /// <param name="position">Die Posititon des Fehlers.</param>
        public EbnfException(int position)
        {
            Position = position;
        }

        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="EbnfException"/>-Klasse.
        /// </summary>
        /// <param name="message">Die Fehlermeldung.</param>
        /// <param name="position">Die Posititon des Fehlers.</param>
        public EbnfException(string message, int position) : base(message)
        {
            Position = position;
        }

        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="EbnfException"/>-Klasse.
        /// </summary>
        /// <param name="message">Die Fehlermeldung.</param>
        /// <param name="position">Die Posititon des Fehlers.</param>
        /// <param name="inner">Der Auslöser der Exception.</param>
        public EbnfException(string message, int position, Exception inner)
            : base(message, inner)
        {
            Position = position;
        }
    }

    /// <summary>
    /// Repräsentiert einen Syntax-Fehler.
    /// </summary>
    [Serializable]
    public class SyntaxException : EbnfException
    {
        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="SyntaxException"/>-Klasse.
        /// </summary>
        /// <param name="position">Die Posititon des Fehlers.</param>
        public SyntaxException(int position) : base(position)
        {
        }

        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="SyntaxException"/>-Klasse.
        /// </summary>
        /// <param name="message">Die Fehlermeldung.</param>
        /// <param name="position">Die Posititon des Fehlers.</param>
        public SyntaxException(string message, int position)
            : base(message, position)
        {
        }

        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="EbnfException"/>-Klasse.
        /// </summary>
        /// <param name="message">Die Fehlermeldung.</param>
        /// <param name="position">Die Posititon des Fehlers.</param>
        /// <param name="inner">Der Auslöser der Exception.</param>
        public SyntaxException(string message, int position, Exception inner) : base(message, position, inner)
        {
        }
    }

    /// <summary>
    /// Repräsentiert einen Lexikalischen Fehler.
    /// </summary>
    [Serializable]
    public class LexicalException : EbnfException
    {
        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="LexicalException"/>-Klasse.
        /// </summary>
        /// <param name="position">Die Posititon des Fehlers.</param>
        public LexicalException(int position) : base(position)
        {
        }

        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="LexicalException"/>-Klasse.
        /// </summary>
        /// <param name="message">Die Fehlermeldung.</param>
        /// <param name="position">Die Posititon des Fehlers.</param>
        public LexicalException(string message, int position)
            : base(message, position)
        {
        }

        /// <summary>
        /// Initialisiert eine neue Instanz der <see cref="LexicalException"/>-Klasse.
        /// </summary>
        /// <param name="message">Die Fehlermeldung.</param>
        /// <param name="position">Die Posititon des Fehlers.</param>
        /// <param name="inner">Der Auslöser der Exception.</param>
        public LexicalException(string message, int position, Exception inner) : base(message, position, inner)
        {
        }

    }

}
